<%@ page language="java" contentType="text/html; charset=utf8"
	pageEncoding="utf8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<title>Show All Users</title>
<script language="JavaScript" type="text/javascript">
	function submitForm(maxpage) {
		var page = document.getElementById("page").value;
		var patrn = /^[0-9]{1,20}$/;
		if (!patrn.exec(page)) {
			alert("请输入正整数字！");
		} else if (page > maxpage) {
			alert("跳转页码不能超过总页数！");
		} else if (page < 1) {
			alert("跳转页码不能小与1！");
		} else {
			document.getElementById("searchImportTask").submit();
		}
	}
</script>
</head>

<body>
	<table border=1>
		<thead>
			<tr>
				<th>User Id</th>
				<th>First Name</th>
				<th>Last Name</th>
				<th>DOB</th>
				<th>Email</th>
				<th colspan=2>Action</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${pageModel.list}" var="user">
				<tr>
					<td><c:out value="${user.userid}" /></td>
					<td><c:out value="${user.firstName}" /></td>
					<td><c:out value="${user.lastName}" /></td>
					<td><fmt:formatDate pattern="yyyy-MMM-dd" value="${user.dob}" /></td>
					<td><c:out value="${user.email}" /></td>
					<td><a
						href="UserController?action=edit&userId=<c:out value="${user.userid}"/>">Update</a></td>
					<td><a
						href="UserController?action=delete&userId=<c:out value="${user.userid}"/>">Delete</a></td>
				</tr>
			</c:forEach>
		</tbody>
	</table>

	<p>
		<a href="UserController?action=insert">Add User</a>
	</p>
	<p class="result">
		共 <b class="red">${pageModel.recordCount}</b> 条 共 <b class="red">${pageModel.totalPage}</b>
		页 第 <b class="red">${pageModel.currentPage}</b> 页
		<c:choose>
			<c:when test="${pageModel.currentPage==pageModel.totalPage}">
      下一页 末页
             </c:when>
			<c:otherwise>
				<a
					href="UserController?action=listUser&page=${pageModel.currentPage+1}">下一页</a>
				<a href="UserController?action=listUser&page=${pageModel.totalPage}">末页</a>
			</c:otherwise>
		</c:choose>
		<c:choose>
			<c:when test="${pageModel.currentPage==1}">
      首页 上一页
             </c:when>
			<c:otherwise>
				<a href="UserController?action=listUser&page=1">首页</a>
				<a
					href="UserController?action=listUser&page=${pageModel.currentPage-1}">上一页</a>
			</c:otherwise>
		</c:choose>
	<form action="UserController" method="get" id="searchImportTask">
		<input name="action" value="listUser" type="hidden" /> <input
			name="page" id="page" type="text" class="input_blur" /> <a
			href="javascript:submitForm(${pageModel.totalPage});" target="_self"
			class="go">GO</a>

	</form>
	</p>

</body>
</html>